package com.zenithmind.chat.exception;

/**
 * AI聊天业务异常
 * 遵循单一职责原则，专门处理AI聊天相关的业务异常
 */
public class AiChatException extends RuntimeException {
    
    private final int code;
    
    public AiChatException(String message) {
        super(message);
        this.code = 500;
    }
    
    public AiChatException(int code, String message) {
        super(message);
        this.code = code;
    }
    
    public AiChatException(String message, Throwable cause) {
        super(message, cause);
        this.code = 500;
    }
    
    public AiChatException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
    
    public int getCode() {
        return code;
    }
    
    // === 静态工厂方法 - 遵循开闭原则 ===
    
    public static AiChatException chatNotFound(String chatId) {
        return new AiChatException(404, "对话不存在: " + chatId);
    }
    
    public static AiChatException modelNotSupported(String modelType) {
        return new AiChatException(400, "不支持的模型类型: " + modelType);
    }
    
    public static AiChatException configurationInvalid(String reason) {
        return new AiChatException(400, "配置无效: " + reason);
    }
    
    public static AiChatException permissionDenied(String operation) {
        return new AiChatException(403, "权限不足: " + operation);
    }
    
    public static AiChatException streamProcessingFailed(String reason) {
        return new AiChatException(500, "流式处理失败: " + reason);
    }
    
    public static AiChatException aiServiceUnavailable(String serviceName) {
        return new AiChatException(503, "AI服务不可用: " + serviceName);
    }
}
